/*
 * Copyright (c) 2023 Huawei Technologies Co., Ltd.
 * openUBMC is licensed under Mulan PSL v2.
 * You can use this software according to the terms and conditions of the Mulan PSL v2.
 * You may obtain a copy of Mulan PSL v2 at:
 *         http://license.coscl.org.cn/MulanPSL2
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PSL v2 for more details.
 */

#ifndef I2C_H
#define I2C_H

#include "interface/i_i2c.h"
#include "internal/bus/bus_base/bus.h"
#include "internal/hasdef.h"
#include <mc/engine.h>
#include <memory>

/*
Id 总线号
Speed 速率
Mode 模式
SlaveAddr 从机地址
UseSmbus 使用SMBus
"I2c": {
    "bmc.dev.Bus.I2c": {
        "Id": 0,
        "Speed": 0,
        "Mode": 0,
        "SlaveAddr": 0,
        "UseSmbus": 0
    }
}
*/

namespace dev {

class I2c_object : public mc::engine::object<I2c_object> {
public:
    MC_OBJECT(I2c_object, "I2c_object", "${object_name}", (Interface_I2c))

    I2c_object()  = default;
    ~I2c_object() = default;

    bool    init(mc::mutable_dict& csr_object, const mc::dict& connector);
    uint8_t get_id();

    Interface_I2c m_interface_i2c;
};

} // namespace dev

#endif // I2C_H
